<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import musicSongType from '@/api/music/musicSongType'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()



const switchStatus = (statusValue, id, statusName) => {
  musicSongType.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'music_song_type',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: 600
  },
  api: musicSongType.getList,
  recycleApi: musicSongType.getRecycleList,
  add: {
    show: true,
    api: musicSongType.save,
    auth: ['music:songType:save']
  },
  edit: {
    show: true,
    api: musicSongType.update,
    auth: ['music:songType:update']
  },
  delete: {
    show: true,
    api: musicSongType.deletes,
    auth: ['music:songType:delete'],
    realApi: musicSongType.realDeletes,
    realAuth: ['music:songType:realDeletes']
  },
  recovery: {
    show: true,
    api: musicSongType.recoverys,
    auth: ['music:songType:recovery']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "歌曲类型名称",
    dataIndex: "name",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入歌曲类型名称"
    }
  },
  {
    title: "图片",
    dataIndex: "img",
    formType: "input",
    search: true
  },
  {
    title: "状态",
    dataIndex: "status",
    formType: "select",
    search: true,
    dict: {
      data: [
        {
          label: "正常",
          value: "1"
        },
        {
          label: "隐藏",
          value: "2"
        }
      ],
      translation: true
    }
  },
  {
    title: "权重",
    dataIndex: "weigh",
    formType: "input",
    search: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  }
])
</script>
<script> export default { name: 'music:songType' } </script>